{extend name="base" /}
{block name="body"}
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class=""><a href="{:url('admin/system/siteConfig')}">站点配置</a></li>
            <li class="layui-this">上传配置</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form form-container" action="{:url('admin/system/updateUploadConfig')}"
                      method="post">
                    <div class="layui-form-item">
                        <label class="layui-form-label">上传方式</label>
                        <div class="layui-input-block upload-type">
                            <input type="radio" name="upload_config[upload_type]" {if condition="$upload_config.upload_type==1"} checked{/if} value="1" title="默认上传">
                            <input type="radio" name="upload_config[upload_type]" {if condition="$upload_config.upload_type==2"} checked{/if} value="2" title="阿里云OSS">
                        </div>
                    </div>
                    <div class="oss">
                        <div class="layui-form-item">
                            <label class="layui-form-label">Access Key ID</label>
                            <div class="layui-input-block">
                                <input type="text" name="upload_config[key_id]"
                                       value="{$upload_config.key_id|default=''}" placeholder="请输入您的Access Key ID"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">Access Key Secret</label>
                            <div class="layui-input-block">
                                <input type="text" name="upload_config[key_secret]"
                                       value="{$upload_config.key_secret|default=''}" placeholder="请输入您的Access Key Secret"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">外网地址Endpoint</label>
                            <div class="layui-input-block">
                                <input type="text" name="upload_config[endpoint]"
                                       value="{$upload_config.endpoint|default=''}" placeholder="请输入阿里云oss 外网地址endpoint"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">Bucket</label>
                            <div class="layui-input-block">
                                <input type="text" name="upload_config[bucket]"
                                       value="{$upload_config.bucket|default=''}" placeholder="请输入Bucket名称"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="*">提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script>
    $(function () {
        //默认选择
        if($('.upload-type input').eq(0).is(':checked')) {
            $('.oss').hide();
        }
        if($('.upload-type input').eq(1).is(':checked')) {
            $('.oss').show();
        }

        //选择
        $('.upload-type').on('click',function () {
            if($(this).find('input').eq(0).is(':checked')) {
                $('.oss').hide();
            }
            if($(this).find('input').eq(1).is(':checked')) {
                $('.oss').show();
            }
        });
    });
</script>
{/block}